package core;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.util.Scanner;
import java.io.*;

import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.parser.PdfReaderContentParser;
import com.itextpdf.text.pdf.parser.SimpleTextExtractionStrategy;
import com.itextpdf.text.pdf.parser.TextExtractionStrategy;



public class TestSystem {
	
	  
	public void deleteUnnecessaryFiles(){
		//TODO COMPLETAR
	}
	

	public static void main(String[] args) {	
		
		 String[] charsetsToBeTested = {"UTF-8", "windows-1253", "ISO-8859-7","Windows-1251","GB2312","ISO-8859-1","ISO-8859-2","Windows-1252"};
		 
		 CharsetDetector cd = new CharsetDetector();
		 ConvertPdfToTxt convert = new ConvertPdfToTxt();       
	       
	       
	       //List the Directories
	       File root = new File("docs");
	       
	       File[] directories =root.listFiles();
	       
	      /* for(int i=0;i<directories.length;i++){
	    	   File[] files = directories[i].listFiles();
	    	   
	    	   for(int j=0;j<files.length;j++){
	    		   //Files
	    		   Charset charset = cd.detectCharset(files[j], charsetsToBeTested);
	    		   
	    		   System.out.println("LISTA DE ARCHIVOS: "+files[j].getPath());
	    		   
	    	      
	    		   if(charset==null){   		    	       
	    	    	   
	    	    	   if(files[j].length()==0){
	    	    		   System.out.println(files[j].getName());
	    	    		//The file is empty
	    	    		   files[j].delete();
	    	    	   }
	    	    	   
	    	       }
	    		   else{
	    			   
	    			   if(convert.isPDF(files[j].getPath())){
    	    			   try {
    	    				   //TODO
    	    				   System.out.println("Archivos PDF: "+files[j].getName());
							convert.parsePdf(files[j].getPath(), files[j].getPath()+"pdf");
							files[j].delete();
							
							
						} catch (IOException e) {
							System.out.println("FALLO AL CONVERTIR DE PDF A TXT");
						}
    	    			   
    	    			     	    			   
    	    			   
    	    			   
    	    		   }
	    		   }
	    		   
	    	   }
	       }*/
	    
	        
		ManagerFile managerFile = new ManagerFile();
		File bart = new File("docs/bart/1");
		//TODO PROVISIONAL
		//managerFile.storeDoc(bart);
		managerFile.MLE(bart);
		
	     
	      
	   
		

	}

}
